<template>
  <div class="contact-page">
    <h1>{{ $t('routeTitles.contact-us') }}</h1>
    <div class="contact-container">
      <div class="contact-info">
        <h2>{{ $t('contact.title') }}</h2>
        <div class="info-item">
          <span class="icon location"></span>
          <!-- <p>{{ factoryInfo.address }}</p> -->
        </div>
        <div class="info-item">
          <span class="icon phone"></span>
          <!-- <p>{{ factoryInfo.contactPhone }}</p> -->
        </div>
        <div class="info-item">
          <span class="icon email"></span>
          <!-- <p>{{ factoryInfo.contactEmail }}</p> -->
        </div>
      </div>
      <div class="contact-form">
        <h2>{{ $t('contact.formTitle') }}</h2>
        <form @submit.prevent="submitForm">
          <div class="form-group">
            <input type="text" v-model="form.name" :placeholder="$t('contact.name')" required>
          </div>
          <div class="form-group">
            <input type="email" v-model="form.email" :placeholder="$t('contact.email')" required>
          </div>
          <div class="form-group">
            <textarea v-model="form.message" :placeholder="$t('contact.message')" rows="5" required></textarea>
          </div>
          <button type="submit">{{ $t('contact.submit') }}</button>
        </form>
      </div>
    </div>
  </div>
</template>

<script>
import { useFactoryStore } from '@/store/factoryInfo.js'
import { storeToRefs } from 'pinia'
import { reactive } from 'vue'
import { useRouter } from 'vue-router'

export default {
  setup() {
    const factoryStore = useFactoryStore()
    console.log('Factory store:', storeToRefs(factoryStore))
    const { state: factoryInfo } = storeToRefs(factoryStore)
    const router = useRouter()
    const form = reactive({
      name: '',
      email: '', 
      message: ''
    })

    const submitForm = () => {
      console.log('Form submitted:', form)
      router.push('/thank-you')
    }
    
    return {
      form,
      factoryInfo,
      submitForm
    }
  }
}
</script>

<style scoped>
.contact-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.contact-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  margin-top: 2rem;
}

.info-item {
  display: flex;
  align-items: center;
  margin: 1rem 0;
}

.icon {
  display: inline-block;
  width: 24px;
  height: 24px;
  margin-right: 1rem;
  background-size: contain;
}

/* .location { background-image: url('@/assets/icons/location.svg'); }
.phone { background-image: url('@/assets/icons/phone.svg'); }
.email { background-image: url('@/assets/icons/email.svg'); } */

.form-group {
  margin-bottom: 1.5rem;
}

input, textarea {
  width: 100%;
  padding: 0.8rem;
  border: 1px solid #ddd;
  border-radius: 4px;
}

button {
  background-color: #007bff;
  color: white;
  padding: 0.8rem 2rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
</style>
